package cn.marknum.gateway.filter;//package springcloud;
//
//import org.slf4j.Logger;
//import org.slf4j.LoggerFactory;
//import org.springframework.cloud.gateway.filter.GatewayFilter;
//import org.springframework.cloud.gateway.filter.GatewayFilterChain;
//import org.springframework.core.Ordered;
//import org.springframework.web.server.ServerWebExchange;
//import reactor.core.publisher.Mono;
//
///**
// * @Description: 自定义过滤器
// * @Author: wangxiaohong
// * @Date: 11:59 2019-08-22
// */
//public class CustomFilter implements GatewayFilter, Ordered {
//
//    private static final Logger LOGGER = LoggerFactory.getLogger(CustomFilter.class);
//    private static final String REQUEST_TIME_BEGIN = "requestTimeBegin";
//
//    @Override
//    public Mono<Void> filter(ServerWebExchange exchange, GatewayFilterChain chain) {
//        exchange.getAttributes().put(REQUEST_TIME_BEGIN, System.currentTimeMillis());
//        return chain.filter(exchange).then(
//                Mono.fromRunnable(() -> {
//                    Long startTime = exchange.getAttribute(REQUEST_TIME_BEGIN);
//                    if (startTime != null) {
//                        LOGGER.info(exchange.getRequest().getURI().getRawPath() + ": " + (System.currentTimeMillis() - startTime) + "ms");
//                    }
//                })
//        );
//    }
//
//    @Override
//    public int getOrder() {
//        return 0;
//    }
//}
